perf: raise build target to ES2022#145
Open
layershifter wants to merge 8 commits intomicrosoft:mainfrom
Open
Conversation
Four-PR plan to shrink keyborg's emitted bundle: drop the IE11 WeakRef shim, refactor classes to closures for better minification, then measure ES2022 target and plain tsc emit as spikes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
First implementation plan in the bundle-size reduction stack. Subsequent PRs (closure refactor, ES2022 spike, tsc-emit spike) will get their own plans as the stack progresses. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
.browserslistrc excludes IE 11, so the shim's fallback path was unreachable. Replace with native WeakRef, remove the companion Disposable interface, and delete the unused KeyborgCore.isDisposed() method (its body `return !!this._win` was inverted — returned true before dispose — which confirms nothing on the supported path ever called it). Bundle-size deltas on measurement fixtures: - All exports: -385 B min / -120 B gz - createKeyborg + disposeKeyborg: -385 B min / -124 B gz - KEYBORG_FOCUSIN constant: no change Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The deletion was intended in the previous refactor commit but got dropped during a stash/pop round-trip. The file is already unused (no importers) so the bundle shape is unchanged — this just removes the now-dead file from the source tree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces class KeyborgCore and class Keyborg with factory functions.
Per-instance state moves from this._x fields (which minifiers cannot
mangle at target: "es2019") to closure locals (which they can). Public
API unchanged: createKeyborg, disposeKeyborg, and the Keyborg type
(now an interface) keep the same shape. WindowWithKeyborg.__keyborg
retains its outer { core, refs } shape.
Bundle-size deltas vs post-PR-1 baseline:
- All exports: -1.693 kB min / -212 B gz
- createKeyborg + disposeKeyborg: -1.693 kB min / -211 B gz
- KEYBORG_FOCUSIN constant: no change
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
At es2022, class fields, #private syntax, optional chaining and nullish coalescing are native — no transpilation helpers. The closure refactor in microsoft#144 already eliminated the class bodies, so the remaining wins come from lib-level features. Bundle-size deltas vs post-microsoft#144 baseline: - All exports: -281 B min / -90 B gz - createKeyborg + disposeKeyborg: -242 B min / -78 B gz - KEYBORG_FOCUSIN constant: no change Decision rule (>=2% min shrink, no gz regression) satisfied: min shrinks 5.2-5.7%, gz shrinks 4.6-5.2%. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📊 Bundle size reportUnchanged fixtures
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
targetintsdown.config.mtsfromes2019toes2022. At ES2022, class fields, private identifiers, optional chaining, and nullish coalescing are emitted natively instead of being transpiled into helpers..browserslistrc(defaults, not IE 11) comfortably supports ES2022 — thedefaultsquery resolves to browser versions from late 2021 onward, all of which ship ES2022 syntax.downlevel-dtsis unaffected: it only rewrites emitted.d.tsfiles and does not see the runtime target.Stacking
PR 3 of the bundle-size reduction stack, stacked on #144 (
perf: refactor Keyborg classes to closure-based factories). Until #144 merges, this PR's diff will include #144's commits. Please review only the final commit here; the prior commits are under review in #144.Bundle size
Baseline = post-#144 tip.
createKeyborg()&disposeKeyborg()KEYBORG_FOCUSINconstantSpike decision rule (≥2% min shrink, no gz regression) satisfied on both non-trivial fixtures.
Test plan
npm run buildsucceedsnpm test— 9/9 Playwright specs pass locallynpm run bundle-sizeshows shrinkage on both non-trivial fixtures🤖 Generated with Claude Code